import store from '../../westore/store'
import create from '../../westore/utils/create'

import Config from "../../config"
import Api from "../../utils/api"
import {
  Modal
} from "../../utils/common"
import deepCopy from "../../utils/common"
const app = getApp(),
  regeneratorRuntime = require("../../utils/regenerator-runtime/runtime")

create(store, {
  /**
   * 页面的初始数据
   */
  data: {
    openid:"",
    focus: false,
    searchState: false,
    theActivityData:[],
    id:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const _this = this;
    _this.setData({
      id:options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady:async function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: async function () {
    wx.showLoading({
      title: '加载中',
    })
    const _this = this;
    const openid = _this.store.data.openid;
    const res = await Api.getActivityebyId(openid,_this.data.id);
    wx.hideLoading();
    if(res.status==0){
      _this.setData({
        theActivityData: [res.data]
      })
    }
  },

  goAddActivity: function (e) {
    const thetype = e.currentTarget.dataset.thetype
    const actid = e.currentTarget.dataset.actid
    // console.log(e.currentTarget.dataset)
    wx.navigateTo({
      url: '/pages/addActivity/addActivity?thetype=' + thetype + '&theactid=' + actid
    })
  },
  showInput: function showInput() {
    this.setData({
      focus: true,
      searchState: true
    });
  },
  hideInput: function hideInput() {
    this.setData({
      focus: false,
      searchState: false
    });
  },
  search: async function(){
    wx.showLoading({
      title: '',
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})